home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
5
/
CRON_1
/
CRON_SET
/
CRON
/
ARGC_BUI.C
next >
Wrap
Text File
|
1991-09-22
|
3KB
|
118 lines
/* ╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
Filename: "argc Builder.c"
argc/argv argument construction and transmission code, written for
THINK C 5.0
By Chris Johnson
Version of: Sunday, September 15, 1991 7:00 PM
Distribute freely and without charge, but say something nice about
the author when you use it. Please send me a copy of any improve-
ments you make so they can be incorporated into future versions.
╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤
Internet: chrisj@emx.utexas.edu
UUCP: {husc6|uunet}!cs.utexas.edu!ut-emx!chrisj
BitNet: chrisj@utxvm.bitnet
AppleLink: chrisj@emx.utexas.edu@internet#
CompuServe: >INTERNET:chrisj@emx.utexas.edu
US Mail: Chris Johnson, 3311 Red River #305, Austin, TX 78705
╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤╤ */
#include "argc Builder.h"
#include "StrBuff Arg Util.h"
#include ":::Standard Code:BufferMgr.h"
#define argcEventClass 'args'
#define argcEventID 'argc'
#define argcKeyword 'argc'
OSErr argcCreate(argcDesc)
AEDesc *argcDesc;
{
return (AECreateList(NULL, 0, FALSE, argcDesc));
}
OSErr argcDispose(argcDesc)
AEDesc *argcDesc;
{
return (AEDisposeDesc(argcDesc));
}
OSErr argcAddP(argcDesc, ArgStringP)
AEDesc *argcDesc;
StringPtr ArgStringP;
{
return (AEPutPtr(argcDesc, 0, typeChar, (Ptr) ArgStringP + 1, *ArgStringP));
}
OSErr argcAddC(argcDesc, ArgStringC)
AEDesc *argcDesc;
unsigned char *ArgStringC;
{
long ArgStringLen;
unsigned char *ArgChar;
ArgStringLen = 0;
ArgChar = ArgStringC;
while (*ArgChar++ != '\0')
ArgStringLen++;
return (AEPutPtr(argcDesc, 0, typeChar, (Ptr) ArgStringC, ArgStringLen));
}
OSErr argcAddB(argcDesc, Buffer, BuffSize)
AEDesc *argcDesc;
Ptr Buffer;
long BuffSize;
{
return (AEPutPtr(argcDesc, 0, typeChar, Buffer, BuffSize));
}
OSErr argcSend(argcDesc, ProcessNumber)
AEDesc *argcDesc;
ProcessSerialNumber *ProcessNumber;
{
OSErr OSError;
AEAddressDesc Target;
OSError = AECreateDesc(typeProcessSerialNumber, (Ptr) ProcessNumber, sizeof(*ProcessNumber), &Target);
if (OSError == noErr) {
AppleEvent argcEvent;
OSError = AECreateAppleEvent(argcEventClass, argcEventID, &Target, kAutoGenerateReturnID, 0, &argcEvent);
if (OSError == noErr) {
OSError = AEPutParamDesc(&argcEvent, argcKeyword, argcDesc);
if (OSError == noErr) {
AppleEvent argcReplyEvent;
// Note that we won't have to dispose of the reply event because
// we specify kAENoReply when we send the original event.
OSError = AESend(&argcEvent, &argcReplyEvent, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
}
AEDisposeDesc(&argcEvent);
}
AEDisposeDesc(&Target);
}
return (OSError);
}